package com.example.schoolguider.controller;

import com.example.schoolguider.common.Result;
import com.example.schoolguider.common.ResultStatus;
import com.example.schoolguider.model.Area;
import com.example.schoolguider.model.Layer;
import com.example.schoolguider.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wjc
 * @date 2024/6/30 8:48
 */
@RestController
@RequestMapping("/area")
public class AreaController {
    @Autowired
    AreaService areaService;
    @RequestMapping("/ua/listAreas")
    public Result listAreas() {
        return Result.of(ResultStatus.SUCCESS, areaService.listAreas());
    }
    @RequestMapping("/ua/getAreaById")
    public Result getAreaById(Long id) {
        return Result.of(ResultStatus.SUCCESS, areaService.getAreaById(id));
    }
    @RequestMapping("/ua/listLayerByAreaId")
    public Result listLayerByAreaId(Long areaId) {
        return Result.of(ResultStatus.SUCCESS, areaService.listLayerByAreaId(areaId));
    }
    @RequestMapping("/ua/getLayerById")
    public Result getLayerById(Long id) {
        return Result.of(ResultStatus.SUCCESS, areaService.getLayerById(id));
    }
    @RequestMapping("/updateLayer")
    public Result updateLayer(@RequestBody Layer layer) {
        return Result.of(ResultStatus.SUCCESS, areaService.updateLayer(layer));
    }
    @RequestMapping("/addLayer")
    public Result addLayer(@RequestBody Layer layer) {
        return Result.of(ResultStatus.SUCCESS, areaService.addLayer(layer));
    }
    @RequestMapping("/updateArea")
    public Result updateArea(@RequestBody Area area) {
        return Result.of(ResultStatus.SUCCESS, areaService.updateArea(area));
    }
}
